package com.dk.controller;

import com.dk.em.Result;
import com.dk.pojo.WmItemRecpt;
import com.dk.service.wmItemRecptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("wmitemrecpt")
@Api(tags = "采购入库服务")
public class wmItemRecptController {

    @Autowired
    private wmItemRecptService itemRecptService;

    /*增加*/
    @PostMapping
    @ApiOperation("添加物料入库单")
    public Result insertitemrecpt(@RequestBody WmItemRecpt itemRecpt){
        itemRecptService.insertitemrecpt(itemRecpt);
        return Result.OK();
    }

    /*根据id删除*/
    @DeleteMapping
    @ApiOperation("删除物料入库单")
    @ApiImplicitParam(name = "物料入库单id",value = "id")
    public Result deleteitemrecpt(Long id){
        itemRecptService.deleteById(id);
        return Result.OK();
    }

    /*批量删除*/
    @DeleteMapping("deleteAllItem")
    public Result deleteAllItem(@RequestBody List<String> ids){
        itemRecptService.deleteAllByIds(ids);
        return Result.OK();
    }

    /*查询*/
    @GetMapping
    @ApiOperation("查询物料入库单")
    public Result getitemrecpt(){
        List<WmItemRecpt> list = itemRecptService.selectItemRecpt();
        return Result.OK().setData(list);
    }

    /*修改*/
    @PutMapping
    @ApiOperation("修改物料入库单")
    public Result updateitemrecpt(@RequestBody WmItemRecpt itemRecpt){
        itemRecptService.updateItem(itemRecpt);
        return Result.OK();
    }
}
